let list = null
let zan = null
async function get() {
  list = await axios({
    url: 'index/index',
  }).then(res => {
    console.log(res.data.data)
    return res.data.data
  })
  zan = await axios({
    url: 'user/userDataList',
    headers: { token: localStorage.getItem('token') },
    params: {
      type: 1,
      page: 1,
      limit: 10,
    },
  }).then(res => {
    console.log(res.data.data.list.data)
    return res.data.data.list.data
  })
  new Vue({
    el: '.shw',
    data: {
      allCate: list.allCate,
      banner: list.banner,
      sideBanner: list.sideBanner,
      allTag: list.allTag,
      allLink: list.allLink,
      token: localStorage.getItem('token'),
      user: JSON.parse(localStorage.getItem('user')),
      zan,
      clear: true,
    },
    filters: {
      www(val) {
        let day = new Date(val).getDate()
        day = day < 10 ? '0' + day : day
        let m = new Date(val).getMonth() + 1
        m = m < 10 ? '0' + m : m
        let y = new Date(val).getFullYear()
        y = y < 10 ? '0' + y : y
        return y + '-' + m + '-' + day
      },
    },
    conputed: {},
    methods: {
      delGood(e) {
        console.log()

        axios({
          url: 'user/userDataHandle',
          headers: { token: this.token },
          params: {
            type: 1,
            article_id: zan[e.target.getAttribute('index')].id,
            action: 'del',
          },
        }).then(res => {
          if (res.status != 200) return layer.msg('修改失败')
          layer.msg(res.data.data)
          zan.splice(e.target.getAttribute('index'), 1)
        })
      },
      fy(e) {
        if (e.target.localName === 'a' || e.taget.localName === em) {
          this.newIndex = newIndex
        }
      },
      rem() {
        layer.confirm(
          '确认退出？',
          {
            btn: ['确认', '取消'], //可以无限个按钮
          },
          function (index, layero) {
            //按钮【按钮一】的回调
            localStorage.clear()
            location.href = '/web-static/index.html'
          },
          function (index) {
            //按钮【按钮二】的回调
          },
        )
      },
    },
  })
}
get()
